<%--
  Created by IntelliJ IDEA.
  User: Hexun
  Date: 2017/8/1 0001
  Time: 15:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>体校考试系统</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="stylesheet" href="/assets/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/assets/css/admin.css">
    <link rel="stylesheet" href="/assets/css/app.css">
    <script src="/assets/js/jquery.min.js"></script>
    <script>

    </script>
</head>
<body>
<%@ include file="/NavMenu.jsp" %>
<div style="float: left;margin-left: 2%;width: 76%">
    <div class="tpl-portlet-components">
        <div class="portlet-title">
            <div class="caption font-green bold" style="width: 100%;">
                <span class="am-icon-code"></span> 试卷分配
            </div>
        </div>
        <div class="tpl-block">
            <table class="am-table  am-table-hover am-text-center table-main ">
                <tr>
                    <td colspan="4">考试科目列表</td>
                </tr>
                <tr>
                    <td>编号</td>
                    <td>考试科目</td>
                    <td>成绩状态</td>
                    <td>是否发布</td>
                </tr>
                <c:forEach var="score" varStatus="s" items="${scoreList}">
                    <td>${s.index}</td>
                    <td>${score.course}</td>

                    <c:choose>
                        <c:when test="${score.isPublic eq 1}">
                            <td>
                                已发布
                            </td>
                            <td>
                                <button class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                        onclick="update('${score.course_id}','0')"> 取消发布
                                </button>
                            </td>
                        </c:when>
                        <c:otherwise>
                            <td>
                                未发布
                            </td>
                            <td>
                                <button class="am-btn am-btn-default am-btn-xs am-text-secondary"
                                        onclick="update('${score.course_id}','1')"> 确认发布
                                </button>
                            </td>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
            </table>

        </div>
        <!--alert模态窗口-->
        <div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
            <div class="am-modal-dialog">
                <div class="am-modal-bd" id="messages">
                </div>
                <div class="am-modal-footer">
                    <span class="am-modal-btn" onclick="ref()">确定</span>
                </div>
            </div>
        </div>
    </div>
    <script>
        function update(course_id, flag) {
            $.get("updatePublic?course_id=" + course_id + "&isPublic=" + flag, function (res) {
                $('#messages').text(res);
                $('#my-alert').modal('open');
            });
        }
        function ref() {
            window.location.href = "publicScores";
        }
    </script>
</div>
</body>
</html>
